-- --------------------------------
-- dZt - ƾڮw榡
-- ({ IT Help tΥΤA)
-- --------------------------------

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

-- 
-- Database: `aitle_detention`
-- 

-- --------------------------------------------------------

CREATE DATABASE `aitle_detention`;
USE `aitle_detention`;

-- 
-- Table structure for table `detention_attendance`
-- 

DROP TABLE IF EXISTS `detention_attendance`;
CREATE TABLE `detention_attendance` (
  `d_id` int(11) NOT NULL,
  `d_date` date NOT NULL default '0000-00-00',
  `d_attcode` tinyint(2) default NULL,
  `d_updatedby` varchar(5) default NULL,
  PRIMARY KEY  (`d_id`,`d_date`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

-- 
-- Table structure for table `detention_outstanding`
-- 

DROP TABLE IF EXISTS `detention_outstanding`;
CREATE TABLE `detention_outstanding` (
  `d_id` int(11) NOT NULL,
  `d_numdays` smallint(6) NOT NULL,
  PRIMARY KEY  (`d_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

-- 
-- Table structure for table `detention_permission`
-- 

DROP TABLE IF EXISTS `detention_permission`;
CREATE TABLE `detention_permission` (
  `d_user` varchar(50) NOT NULL,
  `d_rights` tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (`d_user`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

-- 
-- Table structure for table `detention_record`
-- 

DROP TABLE IF EXISTS `detention_record`;
CREATE TABLE `detention_record` (
  `d_id` int(10) unsigned NOT NULL auto_increment,
  `sid` varchar(15) NOT NULL,
  `tid` varchar(10) NOT NULL,
  `tid2` varchar(10) default NULL,
  `d_reason` varchar(50) NOT NULL,
  `d_action` varchar(50) NOT NULL,
  `d_numdays` smallint(6) NOT NULL default '0',
  `timestamp` datetime NOT NULL,
  PRIMARY KEY  (`d_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

-- 
-- Table structure for table `detention_student`
-- 

DROP TABLE IF EXISTS `detention_student`;
CREATE TABLE `detention_student` (
  `sid` varchar(10) NOT NULL,
  `cls` varchar(3) NOT NULL,
  `cno` smallint(2) NOT NULL,
  `cname` varchar(10) NOT NULL,
  `ename` varchar(50) NOT NULL,
  PRIMARY KEY  (`sid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

-- 
-- Stand-in structure for view `detention_user`
-- 
CREATE TABLE `detention_user` (
`id` int(11)
,`user` varchar(50)
,`pw` varchar(50)
,`name` varchar(50)
,`email` varchar(255)
,`post` varchar(50)
,`adm` tinyint(4)
,`d_user` varchar(50)
,`d_rights` tinyint(4)
);
-- --------------------------------------------------------

-- 
-- Structure for view `detention_user`
-- 
DROP TABLE IF EXISTS `detention_user`;

DROP VIEW IF EXISTS `detention_user`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `aitle_detention`.`detention_user` AS select `i`.`id` AS `id`,`i`.`user` AS `user`,`i`.`pw` AS `pw`,`i`.`name` AS `name`,`i`.`email` AS `email`,`i`.`post` AS `post`,`i`.`adm` AS `adm`,`p`.`d_user` AS `d_user`,`p`.`d_rights` AS `d_rights` from (`aitle_ithelp`.`ithelp_user` `i` join `aitle_detention`.`detention_permission` `p` on((`i`.`user` = `p`.`d_user`)));
